import 'area_list.dart';
import 'area_item.dart';

class CityModel {
  String? code;
  int? level;
  String? name;
  List<AreaItemModel>? industyList;
  List<AreaItemModel>? areaList;

  CityModel({
    this.code,
    this.level,
    this.name,
    this.industyList,
    this.areaList,
  });

  factory CityModel.fromJson(Map<String, dynamic> json) => CityModel(
        code: json['code'] as String?,
        level: json['level'] as int?,
        name: json['name'] as String?,
        industyList: (json['industyList'] as List<dynamic>?)
            ?.map((e) => AreaItemModel.fromJson(e as Map<String, dynamic>))
            .toList(),
        areaList: (json['areaList'] as List<dynamic>?)
            ?.map((e) => AreaItemModel.fromJson(e as Map<String, dynamic>))
            .toList(),
      );

  Map<String, dynamic> toJson() => {
        'code': code,
        'level': level,
        'name': name,
        'industyList': industyList?.map((e) => e.toJson()).toList(),
        'areaList': areaList?.map((e) => e.toJson()).toList(),
      };
}
